﻿@model Bricks.Site.Models.CirculationProcessView
@{
    ViewBag.Title = "CirculationProcess";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}
<head>
    <title></title>
    <script type="text/javascript">
        $(function () {
            //当页面首次刷新的时候执行的事件
            var processCode = $("#hProcessCode").val();
            var processID = $("#hid").val();
            var handleState = $("#hHandleState").val();
            initTable(processCode, processID, handleState);
        });
        //实现对DataGird控件的绑定操作

        function initTable(processCode, processID, handleState) {
            $('#myDataGrid').datagrid({   //定位到Table标签，Table标签的ID是myDataGrid
                //   ActionInfo是控制器，GetData是控制器中获取用户数据的一个Action
                title: '',  //标识
                url: '/Process/SetProcessCirculationData?processCode=' + processCode + '&processID=' + processID + '&handleState=' + handleState,
                //width: 'auto',
                //height: 200,
                nowrap: true,
                autoRowHeight: false,
                striped: true,
                collapsible: true,
                rownumbers: true,
                //sortName: 'ID',    //根据某个字段给easyUI排序
                //sortOrder: 'asc',
                remoteSort: false,
                idField: 'ID',
                columns: [[
                    { title: '下一处理节点', field: 'NodeName', width: 180, sortable: true },
                    { title: '处理人员列表', field: 'DefaultProcessPerson', width: 200, sortable: true },
                ]]
            });
        }

        function SaveCirculationData() {
            var processID = $("#hid").val();
            var processCode = $("#hProcessCode").val();
            var currentProcessNodeCode = $("#hCurrentProcessNodeCode").val();
            var processPersonCondition = $("#hProcessPersonCondition").val();
            var circulationDataList = $('#myDataGrid').datagrid('getData');
            var passNodeList = $("#hPassNodeList").val();
            var approvalOpinion = $("#taApprovalOpinion").val();
            if (approvalOpinion == "") {
                $.messager.alert('操作提示', '审批意见不能为空！', 'info');
            }
            else {
                $.post("/Process/SaveCirculationData?processID=" + processID + "&processCode=" + processCode + "&currentProcessNodeCode=" + currentProcessNodeCode + "&processPersonCondition=" + processPersonCondition + "&nodeCode=" + circulationDataList.rows[0].NodeCode + "&processPersonStr=" + circulationDataList.rows[0].DefaultProcessPerson + "&passNodeList=" + passNodeList + "&approvalOpinion=" + approvalOpinion, function (res) {
                    if (res == "Success") {
                        $.messager.alert('操作提示', '流转成功!', 'info');
                    }
                    else {
                        if (res == "") {
                            $.messager.alert('操作提示', '保存失败!请查看该数据与其他模块下的信息的关联，或联系管理员。', 'info');
                        }
                        else {
                            $.messager.alert('操作提示', res, 'info');
                        }
                    }
                });
            }
        }
    </script>
</head>
<body>
    <div style="padding:5px;">
        <div>
            <input type="hidden" id="hProcessCode" value="@Model.ProcessCode" />
            <input type="hidden" id="hid" value="@Model.ProcessID" />
            <input type="hidden" id="hHandleState" value="@Model.HandleState" />
            <input type="hidden" id="hCurrentProcessNodeCode" value="@Model.CurrentProcessNodeCode" />
            <input type="hidden" id="hProcessPersonCondition" value="@Model.ProcessPersonCondition" />
            <input type="hidden" id="hPassNodeList" value="@Model.PassProcessNodeJson" />
        </div>
        <div region="top" style="height:130px;">
            <table id="myDataGrid" title="" fit="true"></table>
        </div>
        <div region="center" style="border: solid; margin-top: 5px;height:60px;">
            <table>
                <tr>
                    <td style="padding: 5px 15px 5px 5px; text-align: right; width: 70px;"><span>审批意见：</span></td>
                    <td><textarea id="taApprovalOpinion" rows="3" style="width: 300px;"></textarea></td>
                </tr>
            </table>
        </div>
        <div style="margin-left: 5px; margin-top: 5px; text-align: right;">
            <input type="button" id="btnSave" value="保存" onclick="SaveCirculationData();" />
            <input type="button" id="btnCancel" value="取消" />
        </div>
    </div>
</body>
